package training.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class IteratorDemo {
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void main(String[] args) {
		List<Person> daftar = new ArrayList<Person>();

		Person pData = new Person();
		pData.setName("Mpu Tantular");
		pData.setPhone("888-888");
		daftar.add(pData);
		pData.setName("Ken Arok");
		pData.setPhone("123-456");
		daftar.add(pData);
		pData.setName("Gajah Mada");
		pData.setPhone("8080-8080");
		daftar.add(pData);
		
		displayCollection(daftar);
		
		Set personSet = new HashSet();
		personSet.add(pData);
		
		displayCollection(personSet);
		
	}
	
	@SuppressWarnings("rawtypes")
	public static void displayCollection(Collection coll){
		Iterator iter = coll.iterator();
		while(iter.hasNext()){
			System.out.println(iter.next().hashCode());
		}
	}
}
